package ink.zhaohui.book.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import ink.zhaohui.book.bo.AbstractBooKBO;

@JsonIgnoreProperties({ "state" })
public class BookVO extends AbstractBooKBO implements IServiceCombVO {
	@Override
	public String getInstanceId() {
		return instanceId;
	}

	@Override
	public void setInstanceId(String instanceId) {
		this.instanceId = instanceId;
	}

	@Override
	public String getCallTime() {
		return callTime;
	}

	@Override
	public void setCallTime(String callTime) {
		this.callTime = callTime;
	}

	private String instanceId;

	private String callTime;

	public static enum State {
		UNKNOWN(0, "未知"), ORDER(100, "下单"), ORDER_CANCEL(200, "下单取消"), ORDER_CANCEL_EX(-201, "下单取消异常"),
		FINISH(300, "订单完成"), FINISH_CANCEL(400, "订单完成取消"), FINISH_CANCEL_EX(-401, "订单完成取消异常");
		private int code;
		private String desc;

		private State(int code, String desc) {
			this.code = code;
			this.desc = desc;
		}

		public int getCode() {
			return code;
		}

		public String getDesc() {
			return desc;
		}

		public static State code2State(int code) {
			switch (code) {
			case 100:
				return ORDER;
			case 200:
				return ORDER_CANCEL;
			case -201:
				return ORDER_CANCEL_EX;
			case 300:
				return FINISH;
			case 400:
				return FINISH_CANCEL;
			case -401:
				return FINISH_CANCEL_EX;
			default:
				return UNKNOWN;
			}
		}
	}

	public State getState() {
		return State.code2State(this.getStateCode());
	}

	public void setState(State state) {
		this.setStateCode(state.getCode());
		;
	}
}
